<html>
<head>
	<meta charset='utf-8' />
	<title>后台管理</title>
	<meta http-equiv="keywords" content="求职,招聘,房屋,出租,出售,求租,求购,宠物,二手,二手车,二手物品,旧货,寻物,寻人,出兑,外兑"> 
	<meta http-equiv="description" content="便民信息网,房屋租售,宠物交易,二手物品,二手车辆,寻物寻人,出兑信息">  
	<meta name="description" content="便民信息网,房屋租售,宠物交易,二手物品,二手车辆,寻物寻人,出兑信息"/>
	<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
	<style>
		@media screen and (max-width:450px){
			#nav_bottom{width:98%;margin:0 auto}
			#content{width:98%;margin:0 auto}
			/*页面宽度900以下时 .abc的宽度为450*/
		}
		@media screen and (min-width:450px){
			#nav_bottom{width:450px;margin:0 auto}
			#content{width:450px;margin:0 auto}
			/*页面宽度900以下时 .abc的宽度为450*/
		}
		.info_item{color:#444;margin:15px 0;display:flex}
		.info_item > div:last-child{flex:1}
	</style>
</head>
<body style='padding:0;margin:0;background:#eee'>
<!-- 1 Content容器 -->
<div id='Content'>
	<!-- 3 内容区-->
	<div style='margin:10px 0;word-break:break-all;padding:10px;'>
		<div style='float:right;text-align:right' onclick='After_Admin_Exit()'>退出</div>

		<h2 style='text-align:center;'>后台管理-关键字管理</h2>
		
	

		<div style='margin:10px auto'>
			<span id='after_fun_select'>

			</span>
			<span style='float:right'>
				<button id='admin_keyword_add_btn'>新增关键字</button>
			</span>
			
			<span id='Refresh_Infinite_Fpage_Data'></span>
		</div>
		<div id='admin_keyword_add_area' style='display:none'>
			<div>
				关键字：<input type="text" id='admin_keyword_add_inp' />
			</div>
			<button id='admin_keyword_add_sub'>提交</button>
			<button id='admin_keyword_add_back'>返回</button>
		</div>

		<hr>

		<!--列表区-->
		<div id='data_list'></div>


		<div style='margin:50px auto;text-align:center' id='fpage'></div>


				

	</div>	<!-- 3 内容区结束-->	

</div><!-- 1 Content容器结束 -->







<!--底部导航容器-->
<div id='Nav_Bottom' style='position:fixed;bottom:0;width:100%;height:45px'>



</body>
</html>


<script src='./Public/jquery.js'></script>
<script src='./Public/fun.js'></script>
<script>
	Check_After_User_Cookie();	//检测登陆状态

	
	var priv_name = 'after_set_keyword';
	Priv_Check(priv_name,function(res){
		if(res != 'ok'){
			alert('没有权限!');
			//location.href = document.referrer;
			exit;
		}
	});
	After_Fun_Select();	//加载后台设置页中的功能选择


	
	Load_NavBottom('after');	//加载底部导航栏

	if(!sessionStorage.after_set_keyword_pnow){
		sessionStorage.after_set_keyword_pnow =1 ;
	}

	$(function(){
		//获取管理员列表
		After_Get_keyword_List();



		//刷新无限分页数据
		Refresh_Infinite_Fpage_Data(function(){
		sessionStorage.after_set_keyword_pnow =1 ;
			After_Get_keyword_List();
		});

		//### 新增关键字
		$('#admin_keyword_add_btn').click(function(){
			var priv_name = 'AfterSetKeyword_Add';
			Priv_Check(priv_name,function(res){
				if(res != 'ok'){
					alert('没有权限!');
					//location.href = document.referrer;
					exit;
				}
			});
			$(this).hide();
			$('#admin_keyword_add_area').show();
		});

		//提交
		$('#admin_keyword_add_sub').click(function(){
			var key = $('#admin_keyword_add_inp').val().trim();
			if(!key){
				alert('不得为空！');return;
			}
			key = ChangeChar(key);
			var type = 'After_keyword_add';
			Token(type,function(token){
				$.ajax({
					url:url,
					type:'post',
					data:{
						token:token,
						type:type,
						key:key
					},
					success(res){
						if(res == 'ok'){
							sessionStorage.after_set_keyword_pnow = 1;
							$('#admin_keyword_add_area').hide();
							$('#admin_keyword_add_btn').show();
							After_Get_keyword_List();
						}else{
							alert('理由已存在或添加失败!');
						}
					}
				});
			});
		});

		//返回
		$('#admin_keyword_add_back').click(function(){
			$('#admin_keyword_add_area').hide();
			$('#admin_keyword_add_btn').show();
		});





	});




	//删除关键字
	function Close_Del(id){
		var priv_name = 'AfterSetKeyword_Del';
		Priv_Check(priv_name,function(res){
			if(res != 'ok'){
				alert('没有权限!');
				//location.href = document.referrer;
				exit;
			}
		});
		if(!confirm('确认删除该组?')){
			return;
		}
		var type = 'After_Keyword_Del';
		Token(type,function(t){
			$.ajax({
				url:url,
				type:'post',
				data:{
					token:t,
					type:type,
					id:id
				},
				success(res){
					if(res == 'ok'){
						alert('删除成功!');
						After_Get_keyword_List();
					}else{
						alert('删除失败!');
					}
				}
			});
		});
	}















	//获取关键字数据列表
	function After_Get_keyword_List(){
		var type = 'After_Get_keyword_List';
		Token(type,function(t){
			$.ajax({
				url:url,
				type:'post',
				data:{
					token:t,
					type:type,
					pnow:sessionStorage.after_set_keyword_pnow
				},
				success(res){
					//alert(res);
					if(!/^{.*}$/.test(res)){
						alert('没有更多数据了!');
						if(sessionStorage.after_set_keyword_pnow > 1){
							sessionStorage.after_set_keyword_pnow = sessionStorage.after_set_keyword_pnow=1;
						}
						$('#fpage a').last().remove();
						return;
					}
					var info = JSON.parse(res);
					var data = info.data;
					var str = '';
					for(var i=0;i<data.length;i++){
						str += "<div style='border-bottom:1px solid #ccc;margin:5px auto;padding-bottom:20px;'>";
						str += "<div>id："+data[i].id;
						str += "　　关键词："+data[i].content+"</div>";
						str += "<div style='text-align:right' class='user_con_btns'>";
						str += "<button onclick=Close_Del("+data[i].id+")>删除</button>";
						str += "</div>";
						str += "</div>";
					}
					$('#data_list').html(str);
				/*	Fpage3(info.PageNo,function(pnow){
						sessionStorage.after_set_keyword_pnow = pnow;
						After_Get_keyword_List();
					});*/
					Fpage4(info.pnow,info.max_page,function(pnow){
						sessionStorage.after_set_keyword_pnow = pnow;
						After_Get_keyword_List();
					},10,3);
				}
			});
		});
	}






</script>

